import { defineConfig } from 'tsdown'

export default defineConfig({
  entry: {
    index: './index.ts',
    'src/node/node-runner': './src/node/node-runner.ts',
    'src/node/get-config': './src/node/get-config.ts',
    'src/node/can-access': './src/node/can-access.ts',
  },
  format: 'esm',
  platform: 'node',
  external: [
    '@amplitude/analytics-node',
    '@standard-schema/spec',
    'ajv',
    'body-parser',
    'colors',
    'dotenv',
    'express',
    'tsx',
    'node-cron',
    'ts-node',
    'tsconfig-paths',
    'uuid',
    'ws',
    'zod',
    // Node built-ins
    'path',
    'fs',
    'child_process',
    'os',
    'util',
    'stream',
    'events',
    'http',
    'https',
    'url',
    'crypto',
    'buffer',
    'zlib',
    'net',
    'node:path',
    'fs/promises',
    'readline',
  ],
  dts: {
    build: true,
  },
  clean: true,
  outDir: 'dist',
  sourcemap: true,
  unbundle: true,
  copy: [
    { from: 'src/python', to: 'dist/src/python' },
    { from: 'src/ruby', to: 'dist/src/ruby' },
    { from: 'src/steps', to: 'dist/src/steps' },
  ],
})
